
<script type="text/javascript">
	$(document).ready(function() {
		$("#offerlist").tablesorter({
			widthFixed: true,
			widgets: ['zebra']
		}).tablesorterPager({
			container: $(".pager")
		});
	});

	function gotocreatepage() {
		var url = "<?php echo site_url($role.'/scholar/offer/add'); ?>";
		document.location.href = url;
	}

	function gotoeditpage(id) {
		var url = "<?php echo site_url($role.'/scholar/offer/edit/').'/'; ?>" + id;
		document.location.href = url;
	}
</script>

<div id="main-content" class="prepend-1 span-19 last">
<?php 
	if ($addstatus == 'success') {
		echo '<span class="info">Beasiswa berhasil ditambahkan.</span><br /><br />';
	} else if ($addstatus == 'failed') {
		echo '<span class="error">Beasiswa gagal ditambahkan. Silakan coba beberapa saat lagi.</span><br /><br />';
	}
	if ($editstatus == 'success') {
		echo '<span class="info">Beasiswa berhasil diedit.</span><div class="clear">'.nbs().'</div>';
	} else if ($editstatus == 'failed') {
		echo '<span class="info">Beasiswa gagal diedit. Silakan coba beberapa saat lagi.</span><div class="clear">'.nbs().'</div>';
	}
?>
	<h3>Daftar Beasiswa yang Ditawarkan</h3>
	<input type="submit" class="submit" name="add" value="Tambah Beasiswa" onclick="gotocreatepage()" />
	<div class="clear"><?php echo nbs(); ?></div>
<?php echo form_open($role.'/scholar/offer/index', array('method' => 'get', 'class' => 'form')); ?>
	<h4>Form Pencarian Beasiswa</h4>
	<table>
		<tr>
			<td width="200"><label>Nama Beasiswa</label></td>
			<td><input type="text" name="name" maxlength="64" style="width: 400px!important" value="<?php echo ext_set_value('name'); ?>" /></td>
		</tr>
		<tr>
			<td><label>Sponsor</label></td>
			<td>
				<select name="sponsor">
					<option value="" <?php echo ext_set_select('sponsor', '', TRUE); ?>>--Silakan pilih sponsor--</option>
<?php 
	foreach ($sponsors as $sponsor) {
		echo '<option value="'.$sponsor->id.'" '.ext_set_select('sponsor', $sponsor->id).'>'.$sponsor->name.'</option>'; 
	}
?>
				</select>
			</td>
		</tr>
	</table>
	<input type="submit" name="search" value="Cari" class="submit" />
<?php echo form_close(); ?>
	<div class="clear"><?php echo nbs(); ?></div>
	<h4><?php echo $title; ?></h4>
	<table id="offerlist">
	<thead>
		<tr>
			<th>Nama Beasiswa</th>
			<th width="120">Awal Periode</th>
			<th width="120">Akhir Periode</th>
			<th width="120">Batas Pengajuan</th>
			<th width="80">Tipe</th>
			<th width="100">Operasi</th>
		</tr>
	</thead>
	<tfoot>
		<?php echo $pager; ?>
	</tfoot>
	<tbody>
<?php 
	if ($scholarships == NULL) :
?>
		<tr>
			<td align="center" colspan="6">
				<span class="info"><?php echo $empty; ?></span>
			</td>
		</tr>
<?php 
	else :
		foreach($scholarships as $scholarship) :
?>
		<tr>
			<td><?php echo anchor($role.'/scholar/offer/detail/'.$scholarship->id, $scholarship->name); ?></td>
			<td align="center"><?php echo date(MONTH_YEAR_FORMAT, strtotime($scholarship->period_start)); ?></td>
			<td align="center"><?php echo date(MONTH_YEAR_FORMAT, strtotime($scholarship->period_end)); ?></td>
			<td align="center"><?php echo date(DAY_FORMAT, strtotime($scholarship->deadline)); ?></td>
			<td align="center"><?php echo $scholarship->type; ?></td>
			<td align="center"><input type="submit" class="submit" name="edit" value="Edit" onclick="gotoeditpage('<?php echo $scholarship->id; ?>')" /></td>
		</tr>
<?php 
		endforeach;
	endif;
?>
	</tbody>
	</table>
	<div class="clear"><?php echo nbs(); ?></div>
</div> 
